package com.promotion.front.dao.user;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Component;

import com.promotion.front.entity.user.User;

@Component
public class UserDao extends SqlSessionDaoSupport {

	public Long addUser(User user) {
		getSqlSession().insert("User.addUser", user);

		return user.getId();
	}

	public void deleteUser(long id) {
		getSqlSession().delete("User.deleteUserById", id);
	}

	public User getUserById(Long id) {
		return (User) getSqlSession().selectOne("User.getUserById", id);
	}

	public User getUserByEmail(String email) {
		return (User) getSqlSession().selectOne("User.searchUserByEmail", email);
	}

	public User getUserByName(String name) {
		return (User) getSqlSession().selectOne("User.searchUserByName", name);
	}

	public User getUserByMobile(String mobile) {
		return (User) getSqlSession().selectOne("User.searchUserByMobile",
				mobile);
	}
}
